from utils.math import mean


def compute_place_coords(warehouse, actions):
    Xs = dict((place.id, []) for place in warehouse.places)
    Ys = dict((place.id, []) for place in warehouse.places)
    for action in actions:
        x, y = action.meta.xy
        Xs[action.place].append(x)
        Ys[action.place].append(y)
        
    for place in warehouse.places:
        x = mean(Xs[place.id])
        y = mean(Ys[place.id])
        place.meta.xy = (x, y)
        
